<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象的解构赋值</title>
</head>
<body>



<script>

    //如果变量名和属性名一样，可以直接省略写法
    //let {name: name, age: age} = {name:'张三',age: '18'}; //完整写法
    /*let {name, age} = {name:'张三',age: '18'}; //省略写法  {属性：变量（值由对应的属性的值来填充）}
    console.log('name',name);*/


    //对象和数组混用
    let {name, age,list:[a,b,c]} = {name:'张三',age: '18',list:[1,2,3]};
    console.log(name, age, a,b,c);

    //如果用大括号表示对象，需要再外层加个中括号，大括号表示的是块级作用域
    let x1,x2;
    //[x1,x2] =[1,2]

    ({x1,x2}={x1:'x1的值1',x2:'x1的值2'})
    console.log(x1, x2);


</script>
</body>
</html>